﻿using System;
using System.Drawing;
using MUnit;

namespace MUnitTests
{
    class TestEquals
    {
        [Test]
        void IntegerEquals()
        {
            Verify.Equals(5, 5);
        }

        [Test]
        [ExpectedException(typeof(FailureException))]
        void IntegerNotEquals()
        {
            Verify.Equals(6, 5);
        }

        [Test]
        [ExpectedException(typeof(FailureException))]
        void NullNotEqualInteger()
        {
            Verify.Equals(null, 5);
        }

        [Test]
        [ExpectedException(typeof(FailureException))]
        void IntegerNotEqualNull()
        {
            Verify.Equals(5, null);
        }


        [Test]
        [ExpectedException(typeof(FailureException))]
        void NullNotEqualNull()
        {
            Verify.Equals(null, null);
        }
    }

    class TestNotEquals
    {
        [Test]
        void IntegerEquals()
        {
            Verify.NotEquals(6, 5);
        }

        [Test]
        [ExpectedException(typeof(FailureException))]
        void IntegerNotEquals()
        {
            Verify.NotEquals(5, 5);
        }

        [Test]
        void NullNotEqualInteger()
        {
            Verify.NotEquals(null, 5);
        }

        [Test]
        void IntegerNotEqualNull()
        {
            Verify.NotEquals(5, null);
        }


        [Test]
        void NullNotEqualNull()
        {
            Verify.NotEquals(null, null);
        }
    }

    class TestIsNull
    {
        [Test]
        void IsNullWorks()
        {
            TestIsNull test = null;

            Verify.IsNull(test);
        }

        [Test]
        [ExpectedException(typeof(FailureException))]
        void IsNullFails()
        {
            TestIsNull test = new TestIsNull();

            Verify.IsNull(test);
        }
    }

    class TestIsNotNull
    {
        [Test]
        void IsNotNullWorks()
        {
            TestIsNull test = new TestIsNull();
            Verify.IsNotNull(test);
        }

        [Test]
        [ExpectedException(typeof(FailureException))]
        void IsNullFails()
        {
            TestIsNull test = null;
            Verify.IsNotNull(test);
        }
    }

    class TestClose
    {
        [Test]
        void CloseWorksByDefault()
        {
            Verify.Close(0.5f, 0.501f);
        }

        [Test]
        [ExpectedException(typeof(FailureException))]
        void CloseFails()
        {
            Verify.Close(0.6f, 0.501f);
        }

        [Test]
        void CloseForPointFWorks()
        {
            Verify.Close(new PointF(0.5f, 0.6f), new PointF(0.501f, 0.601f));
        }

        [Test]
        [ExpectedException(typeof(FailureException))]
        void CloseForPointFFailsForX()
        {
            Verify.Close(new PointF(0.6f, 0.6f), new PointF(0.501f, 0.601f));
        }

        [Test]
        [ExpectedException(typeof(FailureException))]
        void CloseForPointFFailsForY()
        {
            Verify.Close(new PointF(0.5f, 0.5f), new PointF(0.501f, 0.601f));
        }
    }
}
